﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Agency_batchdelete : System.Web.UI.Page
{
   
    
   protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            if (!IsPostBack)
            {
                showSupplyPlan_GoodsView();
            }
        }
        


    }

    public void showPurchaseTableView()
    {



        string strConditions = PurchaseTablefctConditions();
        Db db = new Db();

        DbPage dbPage = new DbPage(db);
        dbPage.Table = "HospitalPurchase ";
        dbPage.Where = strConditions;//要查询的表明
        dbPage.Key = "SupplyGoodsId";                                          //表的主键    
        //查询条件    
        dbPage.SelectField = "case projectid when '8' then '原中标' when '9' then '自行采购' when '10' then '血液制品' when '11' then '重点监控' end as 项目 ,Accountid_YY as 医院编号,PurchasePrice as 价格";
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   

        dbPage.PageSize = 15;                                                    //没有显示记录条数   
       

        dbPage.OrderBy = "SupplyGoodsId";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键



    }
    public string PurchaseTablefctConditions()
    {
        string strtemp = "";
        //strtemp = "SupplyGoodsId in(select SupplyGoodsId from SupplyPlan_Goods WHERE convert(varchar(200),GOODSID)+usercode_tb IN(SELECT convert(varchar(200),药品流水号)+'" + Request.QueryString["UserCode"].ToString() +"' from zixingcaigou)";
        strtemp = "SupplyGoodsId in(select SupplyGoodsId from SupplyPlan_Goods WHERE convert(varchar(200),GOODSID)+usercode_tb IN(SELECT convert(varchar(200),药品流水号)+'" + Request.QueryString["UserCode"].ToString() + "' from zixingcaigou))";

        return strtemp;
    }


    public void showSupplyPlan_GoodsView()
    {



        string strConditions = SupplyPlan_GoodsfctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "SupplyPlan_Goods";
        dbPage.Where = strConditions;//要查询的表明
        dbPage.Key = "SupplyPlan_Goods.SupplyGoodsid";                                          //表的主键    
        //查询条件    
        dbPage.SelectField = " case projectid when '8' then '原中标' when '9' then '自行采购' when '10' then '血液制品' when '11' then '重点监控' end as 项目 ,Productid,CompanyName_TB,CompanyName_PS,sortname";
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   

        dbPage.PageSize = 15;                                                    //没有显示记录条数   


        dbPage.OrderBy = "SupplyPlan_Goods.SupplyGoodsid";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键



    }
    public string SupplyPlan_GoodsfctConditions()
    {
        string strtemp = "";
        strtemp = "convert(varchar(200),GOODSID)+usercode_tb IN(SELECT convert(varchar(200),药品流水号)+'" + Request.QueryString["UserCode"].ToString() + "' from zixingcaigou)";
        return strtemp;
    }
    public void SupplyPlan_GoodsNextView()
    {


        
        string strConditions = SupplyPlan_GoodsNextfctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "dbo.SupplyPlan_GoodsNext";
        dbPage.Where = strConditions;//要查询的表明
        dbPage.Key = "SupplyGoodsId";                                          //表的主键    
        //查询条件    
        dbPage.SelectField = " companyname_ps_M as 主配送企业,companyname_ps_B1 as 分配送企业";
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   

        dbPage.PageSize = 15;                                                    //没有显示记录条数   


        dbPage.OrderBy = "SupplyGoodsid";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键



    }
    public string SupplyPlan_GoodsNextfctConditions()
    {
        string strtemp = "";
        strtemp = "SupplyGoodsId in(select SupplyGoodsId from SupplyPlan_Goods WHERE convert(varchar(200),GOODSID)+usercode_tb IN(SELECT convert(varchar(200),药品流水号)+'" + Request.QueryString["UserCode"].ToString() + "' from zixingcaigou))";
        return strtemp;
    }
    public void project_bidView()
    {



        string strConditions = project_bidfctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "dbo.project_bid ";
        dbPage.Where = strConditions;//要查询的表明
        dbPage.Key = "Bidid";                                          //表的主键    
        //查询条件    
        dbPage.SelectField = " case projectid when '8' then '原中标' when '9' then '自行采购' when '10' then '血液制品' when '11' then '重点监控' end as 项目,Goodsid as 流水号,Accountid as 编号";
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   

        dbPage.PageSize = 15;                                                    //没有显示记录条数   


        dbPage.OrderBy = "Bidid";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键



    }
    public string project_bidfctConditions()
    {
        string strtemp = "";
        strtemp = "convert(varchar(200),GOODSID)+convert(varchar(200),accountid) in(SELECT convert(varchar(200),药品流水号)+convert(varchar(200)," + Request.QueryString["Accountid"].ToString() + ") from zixingcaigou)";
        return strtemp;
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        SupplyPlan_GoodsNextView();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        showSupplyPlan_GoodsView();
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        project_bidView();
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        showPurchaseTableView();
    }
    protected void Button5_Click(object sender, EventArgs e)
    {
       
        
        Response.Write("<script>alert('您确信要删除吗?')</script>");
        Response.Write("<script>alert('您真的要删除吗?')</script>");
        Response.Write("<script>alert('您考虑清楚了吗?')</script>");
        Db db = new Db();
        string delete1 = "delete dbo.SupplyPlan_GoodsNext where SupplyGoodsId in(select SupplyGoodsId from SupplyPlan_Goods WHERE convert(varchar(200),GOODSID)+usercode_tb IN(SELECT convert(varchar(200),药品流水号)+'" + Request.QueryString["UserCode"].ToString() + "' from zixingcaigou))";
        string delete2 = "delete HospitalPurchase where SupplyGoodsId in(select SupplyGoodsId from SupplyPlan_Goods WHERE convert(varchar(200),GOODSID)+usercode_tb IN(SELECT convert(varchar(200),药品流水号)+'" + Request.QueryString["UserCode"].ToString() + "' from zixingcaigou))";
        string delete3 = "delete SupplyPlan_Goods where SupplyGoodsId in(select SupplyGoodsId from SupplyPlan_Goods WHERE convert(varchar(200),GOODSID)+usercode_tb IN(SELECT convert(varchar(200),药品流水号)+'" + Request.QueryString["UserCode"].ToString() + "' from zixingcaigou))";
        string delete4 = "delete project_bid where convert(varchar(200),GOODSID)+convert(varchar(200),accountid) in(SELECT convert(varchar(200),药品流水号)+convert(varchar(200),"+ Request.QueryString["Accountid"].ToString() +") from zixingcaigou)";
        db.Command(delete1);
        db.Command(delete2);
        db.Command(delete3);
        db.Command(delete4);
        db.Close();
        Response.Write("<script>alert('删除成功')</script>");

    }
}
